package com.rmondjone.utils;

import android.app.Activity;
import android.os.Build;

import java.lang.reflect.Method;

/**
 * 状态栏调色, 来自<a href="http://open-wiki.flyme.cn/index.php?title=%E7%8A%B6%E6%80%81%E6%A0%8F%E5%8F%98%E8%89%B2">flyme</a>
 */
public class MeiZuStatusBarUtils {
    private static Method mSetStatusBarDarkIcon;

    static {
        try {
            mSetStatusBarDarkIcon = Activity.class.getMethod("setStatusBarDarkIcon", boolean.class);
        } catch (Exception e) {
            // no-op
        }
    }

    /**
     * 设置状态栏字体图标颜色
     *
     * @param activity 当前activity
     * @param dark     是否深色 true为深色 false 为白色
     */
    public static boolean setStatusBarDarkIcon(Activity activity, boolean dark) {
        if (mSetStatusBarDarkIcon != null) {
            try {
                mSetStatusBarDarkIcon.invoke(activity, dark);
                return true;
            } catch (Exception e) {
                // no-op
            }
        }
        return false;
    }

    public static boolean isMeizuDevice() {
        return Build.MANUFACTURER.equals("Meizu");
    }

}
